<%--
  Created by IntelliJ IDEA.
  User: 北上寻海
  Date: 2022/7/14
  Time: 21:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset='utf-8'>
    <title align='center'>图书馆管理后台</title>
</head>
<body>
<a href='${pageContext.request.contextPath}/exit?method=exit'>[安全退出]</a>
<h3>欢迎${username}，在线人数${onlineCount}</h3>

<%--删除是没有页面展示的，是跳出一个确认框，如果点“确定”，执行删除--%>
<script type="text/javascript">
    function del(dept){
        var ok = window.confirm("亲，删了不可恢复哦！");
        if(ok){
            /*注意html的base标签可能对JS代码不起作用。所以JS代码最好前面写上"/项目名" */
            document.location.href='${pageContext.request.contextPath}/dept/delete?dept='+dept;
        }
    }
</script>

<h1 align='center'>图书管理系统</h1 >
<hr>
<table h1 border = '1px' align='center'>
    <tr>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
    </tr>
    <%--用jstl替代掉jsp--%>
    <c:forEach items="${deptList}" varStatus="deptStatus" var="Dept">
        <tr>
            <td>${deptStatus.count}</td>
            <td>${Dept.dept}</td>
            <td>${Dept.name}</td>
            <td>
                <a href='${pageContext.request.contextPath}/dept/edit?dept= ${Dept.dept}'>修改</a>
                <a href='${pageContext.request.contextPath}/dept/detail?dept=${Dept.dept}'>详情</a>
                <a href='javascript:void(0)' onclick='del(${Dept.dept})'>删除</a>
            </td>
        </tr>
    </c:forEach>

</table>
<hr>
<a href='${pageContext.request.contextPath}/add.jsp' >新增部门</a>
</body>